package com.ruoyi.pet.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.pet.domain.PetDeworming;
import com.ruoyi.pet.service.IPetDewormingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 宠物驱虫记录Controller
 * 
 * @author ruoyi
 * @date 2023-09-01
 */
@RestController
@RequestMapping("/pet/deworming")
public class PetDewormingController extends BaseController
{
    @Autowired
    private IPetDewormingService petDewormingService;

    /**
     * 查询宠物驱虫记录列表
     */
//    @PreAuthorize("@ss.hasPermi('pet:deworming:list')")
    @GetMapping("/list")
    public TableDataInfo list(PetDeworming petDeworming)
    {
        startPage();
        List<PetDeworming> list = petDewormingService.selectPetDewormingList(petDeworming);
        return getDataTable(list);
    }

    /**
     * 导出宠物驱虫记录列表
     */
    @PreAuthorize("@ss.hasPermi('pet:deworming:export')")
    @Log(title = "宠物驱虫记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PetDeworming petDeworming)
    {
        List<PetDeworming> list = petDewormingService.selectPetDewormingList(petDeworming);
        ExcelUtil<PetDeworming> util = new ExcelUtil<PetDeworming>(PetDeworming.class);
        util.exportExcel(response, list, "宠物驱虫记录数据");
    }

    /**
     * 获取宠物驱虫记录详细信息
     */
//    @PreAuthorize("@ss.hasPermi('pet:deworming:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(petDewormingService.selectPetDewormingById(id));
    }

    /**
     * 新增宠物驱虫记录
     */
    @PreAuthorize("@ss.hasPermi('pet:deworming:add')")
    @Log(title = "宠物驱虫记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PetDeworming petDeworming)
    {
        return toAjax(petDewormingService.insertPetDeworming(petDeworming));
    }

    /**
     * 修改宠物驱虫记录
     */
    @PreAuthorize("@ss.hasPermi('pet:deworming:edit')")
    @Log(title = "宠物驱虫记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PetDeworming petDeworming)
    {
        return toAjax(petDewormingService.updatePetDeworming(petDeworming));
    }

    /**
     * 删除宠物驱虫记录
     */
    @PreAuthorize("@ss.hasPermi('pet:deworming:remove')")
    @Log(title = "宠物驱虫记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(petDewormingService.deletePetDewormingByIds(ids));
    }
}
